<?php    
header('Content-type: application/xls');
header("Content-Disposition:attachment;filename=kehoachtuan.xls");

?>
<table >
            <tr><td colspan="4" align="center" style="font-weight: bold; ">
<? echo $tendv ['Zdv'] ['tendvcha'];?>
            </td>
            <td colspan="4" align="center" style="font-weight: bold; ">CỘNG HÒA XÃ HỘI CHỦ NGHĨA VIỆT NAM</td>
            </tr>
            <tr>
            <td colspan="4" align="center" style="font-weight: bold; ">
             <?php
echo $tendv['Zdv'] ['tendv'];
?>
            
             </td>
                <td colspan="4" align="center" style="font-weight: bold; ">Độc lập- tự do- hạnh phúc</td>
            </tr>
            <tr>
            <td colspan="8" align="center" style="font-weight: bold; font-size: large;">
          Kế hoạch công tác Tuần 
            </td>
            </tr>
             
</table>
<div class="khtuans">

<h5><?php echo 'Từ ngày '.date('d/m/Y',strtotime($kh['Kehoach']['ngaybd'])).' đến ngày '
                    .date('d/m/Y',strtotime($kh['Kehoach']['ngaykt']));?>
</h5>
<p>
<?php
echo  __('Gồm '.count($khtuans).' công việc', true);
;
?></p>
<table cellpadding="0" cellspacing="0" id="tables" border="1">
<tr>
	<th style="background: #d5d5d5; font-weight: bold" rowspan="2"><?php echo ('STT');?></th>
	<th style="background: #d5d5d5; font-weight: bold" rowspan="2"><?php echo ('Ngày');?></th>
	<th style="background: #d5d5d5; font-weight: bold" rowspan="2"><?php echo 'Nội dung công việc';?></th>
    <th style="background: #d5d5d5; font-weight: bold" colspan="3">Khối lượng</th>
    <th style="background: #d5d5d5; font-weight: bold" colspan="3">Thành phần</th>
    <th style="background: #d5d5d5; font-weight: bold" colspan="3">Yêu cầu</th>
    <th style="background: #d5d5d5; font-weight: bold" rowspan="2"><?php echo 'Ghi chú';?></th>

	

</tr>
<tr>
    <th style="background: #d5d5d5; font-weight: bold"><?php echo ('Đơn vị tính');?></th>
	<th style="background: #d5d5d5; font-weight: bold"><?php echo ('Mục tiêu');?></th>
	<th style="background: #d5d5d5; font-weight: bold"><?php echo ('Chỉ tiêu giao');?></th>
    <th style="background: #d5d5d5; font-weight: bold"><?php echo 'Chủ trì';?></th>
	<th style="background: #d5d5d5; font-weight: bold"><?php echo 'Người thực hiện';?></th>
	<th style="background: #d5d5d5; font-weight: bold"><?php echo 'Phối hợp';?></th>
    <th style="background: #d5d5d5; font-weight: bold"><?php echo 'Diễn giải';?></th>
	<th style="background: #d5d5d5; font-weight: bold"><?php echo 'Thời gian thực hiện';?></th>
	<th style="background: #d5d5d5; font-weight: bold"><?php echo 'Địa điểm';?></th>
	
	
</tr>
<?php

//foreach ($khtuans as $khtuan):
for($i=0;$i<count($khtuans);$i++){
	$class = null;
	if ($i % 2 == 0) {
		$class = ' class="altrow"';
	}
 //   $i--;
?>
	<tr<?php echo $class;?>>
        <td><?php echo $i+1;?></td>
		 <td>
		
             
             <?php 
             if($i>0){//xet xem 2 dong gan nhau co cung 1 nhan vien khong
                if($khtuans[$i-1]['Khtuan']['ngay']!=$khtuans[$i]['Khtuan']['ngay']){
                     if(date('w',strtotime($khtuans[$i]['Khtuan']['ngay']))==0)
                        echo '<strong>Chủ nhật</strong>';
                    else
                        echo '<strong>Thứ '.(date('w',strtotime($khtuans[$i]['Khtuan']['ngay']))+1).'</strong>';
             
                    echo '<br>';
             
                    echo date('d/m/Y',strtotime($khtuans[$i]['Khtuan']['ngay'])); 
                }
            }
            else{
                if(date('w',strtotime($khtuans[$i]['Khtuan']['ngay']))==0)
                    echo '<strong>Chủ nhật</strong>';
                else
                    echo '<strong>Thứ '.(date('w',strtotime($khtuans[$i]['Khtuan']['ngay']))+1).'</strong>';
             
                echo '<br>';
             
                echo date('d/m/Y',strtotime($khtuans[$i]['Khtuan']['ngay']));
            }
            
           ?>
		</td>
		<td>
			<?php echo $khtuans[$i]['Khtuan']['congviec']; ?>
		</td>
		<td>
			<?php echo $khtuans[$i]['Dvt']['donvitinh']; ?>
		</td>
		<td>
			<?php echo $khtuans[$i]['Khtuan']['muctieu']; ?>
		</td>
		<td>
			<?php echo $khtuans[$i]['Khtuan']['chitieu']; ?>
		</td>
		<td>
			<?php echo $khtuans[$i]['Khtuan']['chutri']; ?>
		</td>
		<td>
			<?php echo $khtuans[$i]['Khtuan']['thuchien']; ?>
		</td>
		<td>
			<?php echo $khtuans[$i]['Khtuan']['phoihop']; ?>
		</td>
		<td>
			<?php echo $khtuans[$i]['Khtuan']['dgiai']; ?>
		</td>
		<td>
			<?php echo date('H\hi',strtotime($khtuans[$i]['Khtuan']['tgian'])).'-'.date('H\hi',strtotime($khtuans[$i]['Khtuan']['tgkt'])); ?>
		</td>
		<td>
			<?php echo $khtuans[$i]['Khtuan']['diadiem']; ?>
		</td>
		<td>
			<?php echo $khtuans[$i]['Khtuan']['ghichu']; ?>
		</td>
		
	
	</tr>
<?php }//endforeach; ?>
</table>
</div>
